﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Calculator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }



        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //实际操作时发现combobox和最后结果的数值都能改动导致无法正常得出结果，查询后进行改动
            comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            textBox3.ReadOnly = true;
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            //不知道这里怎么样检测输入是否为整数遂直接用double
            double a = double.Parse(textBox1.Text);
            double b = double.Parse(textBox2.Text);
            int fun = comboBox1.SelectedIndex;
            double result = 0;
            switch (fun)
            {
                case 0:
                    result = a + b;
                    break;
                case 1:
                    result = a - b;
                    break;
                case 2:
                    result = a * b;
                    break;
                case 3:
                    result = a / b;
                    break;
                case 4:
                    result = a % b;
                    break;
            }
            textBox3.Text = result.ToString();
        }
    }
}
